package com.googlecode.vmock;

/**
 * Result of an intercepted call made in the {@link MockStage#REPLAYING} stage.
 * 
 * @author marcin.jagus
 */
class InterceptionResult {

    /**
     * An interception result which simply informs that the result was not overriden, so a call to original method should be made.
     */
    public static InterceptionResult NOT_OVERRIDEN = new InterceptionResult();

    /**
     * An interception result which informs interception aspect that it needs to wrap a call with recording logic.
     */
    public static InterceptionResult INTERCEPT_RECORDING = new InterceptionResult();

    /**
     * An interception result which informs interception aspect that it needs to wrap a call with replaying logic.
     */
    public static InterceptionResult INTERCEPT_REPLAYING = new InterceptionResult();

    /**
     * Is mocked result available or should original method be called.
     */
    private boolean overridenResult;

    /**
     * Mocked result.
     */
    private Object result;

    /**
     * Creates an interception result without mocked result.
     */
    private InterceptionResult() {
        overridenResult = false;
    }

    /**
     * Creates an interception result with a given mocked result.
     * 
     * @param result given result
     */
    public InterceptionResult(Object result) {
        this.overridenResult = true;
        this.result = result;
    }

    /**
     * Is mocked result available or should original method be called.
     * 
     * @return <code>true</code> if mocked result is available
     */
    public boolean isOverridenResult() {
        return overridenResult;
    }

    /**
     * Returns mocked result. Should always return <code>null</code> if mocked result is not available.
     * 
     * @return mocked result
     */
    public Object getResult() {
        return result;
    }
}
